package com.ruibang.glass.produce.controller.td;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.domain.req.DcsRealTimeDataReq;
import com.ruibang.glass.produce.domain.resp.dcs.td.*;
import com.ruibang.glass.produce.service.DcsTdRealTimeDataService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @Author: songJinKang
 * @CreateTime: 2024-04-23  14:53
 * @Description: TODO:DCS-窑炉实时数据控制器
 * @Version: 1.0
 */

@Api(tags = "DCS-通道实时数据控制器")
@RestController
@RequestMapping("/api/glass/produce/dcs/td")
public class DcsTdRealTimeDataController {

    @Autowired
    private DcsTdRealTimeDataService dcsTdRealTimeDataService;


    /**
     * 查询
     */
    @PostMapping("/queryClarificationSection")
    @ApiOperation(value = "澄清段", response = ResultBody.class)
    public ResultBody<IPage<ClarificationSection>> queryClarificationSection(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryClarificationSection(dcsRealTimeDataReq));
    }


    @PostMapping("/queryCoolingSection")
    @ApiOperation(value = "降温段", response = ResultBody.class)
    public ResultBody<IPage<CoolingSection>> queryCoolingSection(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryCoolingSection(dcsRealTimeDataReq));
    }


    @PostMapping("/queryMixingDrum")
    @ApiOperation(value = "搅拌桶", response = ResultBody.class)
    public ResultBody<IPage<MixingDrum>> queryMixingDrum(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryMixingDrum(dcsRealTimeDataReq));
    }


    @PostMapping("/queryDischargePort")
    @ApiOperation(value = "卸料口", response = ResultBody.class)
    public ResultBody<IPage<DischargePort>> queryDischargePort(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryDischargePort(dcsRealTimeDataReq));
    }


    @PostMapping("/queryCoolingSegment")
    @ApiOperation(value = "冷却段", response = ResultBody.class)
    public ResultBody<IPage<CoolingSegment>> queryCoolingSegment(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryCoolingSegment(dcsRealTimeDataReq));
    }


    @PostMapping("/queryFeedBucket")
    @ApiOperation(value = "供料桶", response = ResultBody.class)
    public ResultBody<IPage<FeedBucket>> queryFeedBucket(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryFeedBucket(dcsRealTimeDataReq));
    }


    @PostMapping("/queryMixerParam")
    @ApiOperation(value = "搅拌机参数", response = ResultBody.class)
    public ResultBody<IPage<MixerParam>> queryMixerParam(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryMixerParam(dcsRealTimeDataReq));
    }


    @PostMapping("/queryCoolingSystem")
    @ApiOperation(value = "冷却系统", response = ResultBody.class)
    public ResultBody<IPage<CoolingSystem>> queryCoolingSystem(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.queryCoolingSystem(dcsRealTimeDataReq));
    }

    /**
     * 趋势图
     */
    @PostMapping("/heatingTrendChart")
    @ApiOperation(value = "升温趋势图", response = ResultBody.class)
    public ResultBody heatingTrendChart(@RequestBody DcsRealTimeDataReq dcsRealTimeDataReq) {
        return ResultBody.success(dcsTdRealTimeDataService.heatingTrendChart(dcsRealTimeDataReq));
    }

    /**
     * 导出
     */
    @PostMapping("/exportClarificationSection")
    @ApiOperation(value = "导出澄清段", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportClarificationSection(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportClarificationSection(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportCoolingSection")
    @ApiOperation(value = "导出降温段", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportCoolingSection(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportCoolingSection(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportMixingDrum")
    @ApiOperation(value = "导出搅拌桶", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportMixingDrum(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportMixingDrum(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportDischargePort")
    @ApiOperation(value = "导出卸料口", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportDischargePort(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportDischargePort(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportCoolingSegment")
    @ApiOperation(value = "导出冷却段", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportCoolingSegment(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportCoolingSegment(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportFeedBucket")
    @ApiOperation(value = "导出供料桶", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportFeedBucket(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportFeedBucket(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportMixerParam")
    @ApiOperation(value = "导出搅拌机参数", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportMixerParam(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportMixerParam(dcsRealTimeDataReq, response);
    }


    @PostMapping("/exportCoolingSystem")
    @ApiOperation(value = "导出冷却系统", response = ResultBody.class)
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 5, target = FrequencyControl.Target.IP)
    public void exportCoolingSystem(@RequestBody @Valid DcsRealTimeDataReq dcsRealTimeDataReq, HttpServletResponse response) {
        dcsTdRealTimeDataService.exportCoolingSystem(dcsRealTimeDataReq, response);
    }
}
